package com.app.config;


import com.app.interceptor.LoginCheckInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.io.File;

@SpringBootConfiguration
public class SpringMvcConfigurationInitializer implements WebMvcConfigurer {

    @Autowired
    private LoginCheckInterceptor loginCheckInterceptor;

//    @Override
//    public void addInterceptors(InterceptorRegistry registry) {
//        registry.addInterceptor(loginCheckInterceptor).addPathPatterns("/**")
//                .excludePathPatterns("/shopAlliance/adminUser/**")
//                .excludePathPatterns("/shopAlliance/adminRole/**")
//                .excludePathPatterns("/shopAlliance/file/**");
//    }


    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/file/**")
                .addResourceLocations(new String[]{"file:" + System.getProperty("user.dir") + File.separator + "file" + File.separator});
        registry.addResourceHandler("/wechat/**")
                .addResourceLocations(new String[]{"file:" + System.getProperty("user.dir") + File.separator + "wechat" + File.separator});
    }
}

